home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / grafix / boards / a2410src.lha / Public / Source / TIGA.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-19  |  28.7 KB  |  736 lines

  1. /* Test mit SetFunction()
  2.  
  3.     28.10.94 
  4.     NewPatches !
  5.     Now it is only drawn to the Screen which is set by GfxSetUpScreen(struct Screen *) !
  6.     There are 3 Functions, which decide if the TIGA is active. The return value is true
  7.     if the active Screen is on the TIGA :
  8.  
  9.     * GfxCheckBitMap(struct BitMap *bm); belongs the Bitmap to the Screen ?
  10.  
  11.     * GfxCheckRP(struct RastPort *rp); does the RastPort belong to the Screen ?
  12.                     well, windows have their own RastPort, use CheckBitMap(RP->BitMap) instead !
  13.  
  14.     * GfxCheckVP(struct ViewPort *vp); dito for ViewPorts !
  15.                     - does not matter , if SetRGBxx() sets the color everytime !
  16.  
  17.     See NewOpenScreenTags() for more information !
  18.  
  19.     Remark the BltBitMap()-Function. It shows, the Emulation is (relativly) stable now. I have
  20.     to rework the BltBitMap() !
  21.     Another bug is in the GfxDraw() function when using the Workbench lasso. Using it the first
  22.     time works. Dragging the Lasso a second time immediately - the machine crashes. If I remove
  23.     the clipping it works. If clicking on screen (all Icons are inactive) , clicking into a window
  24.     and dragging the lasso again - allright works !
  25.  
  26.     30.10.94 I added the PolyDraw() function but don't use it. PolyDraw() does use the OS Move()/Draw()
  27.     command - and because of this PolyDraw() does work without patching ! The TIGA poly_line() could draw
  28.     faster Polygons though - but mine is not 100% comptable and crashes some times - and for drawing
  29.     pattern line polygons I use the GfxDraw() - code ! -> No speed increase !
  30.  
  31.     The Text() Function has to be rewritten. It is not necessary to patch graphic.library's 
  32.     Text(). It uses the BltTemplate() which extracts a 1 bit Mask to a destinatin bitmap.
  33.     I have a similar working version in the EGS-Driver. I will implement it if I am not to lacy...
  34.  
  35.     Also I have a working MouseImage stuff in the EGS-Driver...should build it into the lib by times..
  36. */
  37.  
  38. //#define DEBUG
  39.  
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. #include <exec/types.h>
  43. #include <exec/memory.h>
  44. #include <dos.h>
  45. #include <intuition/intuitionbase.h>
  46.  
  47. #include <pragmas/exec_pragmas.h>
  48. #include <pragmas/graphics_pragmas.h>
  49. #include <pragmas/intuition_pragmas.h>
  50.  
  51. #include "a2410_displayinfo.h"
  52. #include "gfx_pragmas.h"
  53. #include "graphics.h"
  54.  
  55. #define REPLACE TRUE
  56.  
  57. static LONG Busy = FALSE;
  58. struct Library *GfxBase=NULL,*DOSBase=NULL,*DiskfontBase;
  59. struct Library *GspGfxBase=NULL,*GraphicsBase=NULL;
  60. struct IntuitionBase *IntuitionBase=NULL;
  61.  
  62. APTR   Func_Mem;
  63. static BOOL Replace=FALSE,NoExit=FALSE,INSTALLED=FALSE;
  64.  
  65. /* own Prototypes */
  66.  
  67. void CloseTiga(int ExitCode);
  68. void RemovePatch(void);
  69. void InstallPatch(void);
  70.  
  71. void __asm NewClearEOL(register __a1 struct RastPort *rp );  // -0x002a
  72. void (__asm *OldClearEOL)(register __a1 struct RastPort *rp );  // -0x002a
  73. void __asm NewClearScreen(register __a1 struct RastPort *rp );  // -0x0030
  74. void (__asm *OldClearScreen)(register __a1 struct RastPort *rp );  // -0x0030
  75.  
  76. BOOL __asm NewClearRectRegion(register __a0 struct Region *region,register __a1 struct Rectangle *rectangle );  // -0x020a
  77. BOOL (__asm *OldClearRectRegion)(register __a0 struct Region *region,register __a1 struct Rectangle *rectangle );  // -0x020a
  78. void __asm NewClearRegion(register __a0 struct Region *region ); // -0x0210
  79. void (__asm *OldClearRegion)(register __a0 struct Region *region ); // -0x0210
  80.  
  81.  
  82. void __asm NewSetRast(register __a1 struct RastPort *rp,register __d0 unsigned long pen );
  83. void (__asm *OldSetRast)(register __a1 struct RastPort *rp,register __d0 unsigned long pen );
  84.  
  85. void __asm NewMove(register __a1 struct RastPort *,register __d0 SHORT x,register __d1 SHORT y);
  86. void (__asm *OldMove)(register __a1 struct RastPort *,register __d0 SHORT x,register __d1 SHORT y);
  87. void __asm NewDraw(register __a1 struct RastPort *,register __d0 SHORT x,register __d1 SHORT y);
  88. void (__asm *OldDraw)(register __a1 struct RastPort *,register __d0 SHORT x,register __d1 SHORT y);
  89. void __asm NewRectFill(register __a1 struct RastPort *rp,register __d0 long xMin,register __d1 long yMin,
  90.                     register __d2 long xMax,register __d3 long yMax );
  91. void (__asm *OldRectFill)(register __a1 struct RastPort *rp,register __d0 long xMin,register __d1 long yMin,
  92.                     register __d2 long xMax,register __d3 long yMax );
  93. LONG __asm NewWritePixel(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y );
  94. LONG (__asm *OldWritePixel)(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y );
  95. void __asm NewDrawEllipse(register __a1 struct RastPort *rp,register __d0 long xCenter,
  96.                          register __d1 long yCenter,register __d2 long a,register __d3 long b );
  97. void (__asm *OldDrawEllipse)(register __a1 struct RastPort *rp,register __d0 long xCenter,
  98.                          register __d1 long yCenter,register __d2 long a,register __d3 long b );
  99. void __asm NewAreaEllipse(register __a1 struct RastPort *rp,register __d0 long xCenter,
  100.                          register __d1 long yCenter,register __d2 long a,register __d3 long b );
  101. void (__asm *OldAreaEllipse)(register __a1 struct RastPort *rp,register __d0 long xCenter,
  102.                          register __d1 long yCenter,register __d2 long a,register __d3 long b );
  103. LONG __asm NewText(register __a1 struct RastPort *rp,register __a0 STRPTR string,register __d0 unsigned long count );
  104. LONG (__asm *OldText)(register __a1 struct RastPort *rp,register __a0 STRPTR string,register __d0 unsigned long count );
  105. void __asm NewSetRGB4(register __a0 struct ViewPort *vp,register __d0 long index,register __d1 unsigned long red,
  106.                      register __d2 unsigned long green,register __d3 unsigned long blue );
  107. void (__asm *OldSetRGB4)(register __a0 struct ViewPort *vp,register __d0 long index,register __d1 unsigned long red,
  108.                      register __d2 unsigned long green,register __d3 unsigned long blue );
  109. void __asm NewSetRGB32(register __a0 struct ViewPort *vp,register __d0 long n,register __d1 unsigned long r,
  110.                      register __d2 unsigned long g,register __d3 unsigned long b);
  111. void (__asm *OldSetRGB32)(register __a0 struct ViewPort *vp,register __d0 long n,register __d1 unsigned long r,
  112.                      register __d2 unsigned long g,register __d3 unsigned long b);
  113. LONG __asm NewAreaMove(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y );
  114. LONG (__asm *OldAreaMove)(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y );
  115. LONG __asm NewAreaDraw(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y );
  116. LONG (__asm *OldAreaDraw)(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y );
  117. LONG __asm NewAreaEnd(register __a1 struct RastPort *rp);
  118. LONG (__asm *OldAreaEnd)(register __a1 struct RastPort *rp);
  119. void __asm NewPolyDraw(register __a1 struct RastPort *rp,register __d0 long count,register __a0 WORD *polyTable );
  120. void (__asm *OldPolyDraw)(register __a1 struct RastPort *rp,register __d0 long count,register __a0 WORD *polyTable );
  121. LONG __asm NewSetFont(register __a1 struct RastPort *rp,register __a0 struct TextFont *textFont );
  122. LONG (__asm *OldSetFont)(register __a1 struct RastPort *rp,register __a0 struct TextFont *textFont );
  123. void __asm NewMoveSprite(register __a0 struct ViewPort vp,register __a1 struct SimpleSprite *sprite,register __d0 long x,register __d1 long y);
  124. void (__asm *OldMoveSprite)(register __a0 struct ViewPort vp,register __a1 struct SimpleSprite *sprite,register __d0 long x,register __d1 long y);
  125. LONG __asm NewBltBitMap(register __a0 struct BitMap *srcBitMap,
  126.     register __d0 long xSrc,register __d1 long ySrc,
  127.     register __a1 struct BitMap *destBitMap,
  128.     register __d2 long xDest,register __d3 long yDest,register __d4 long xSize,
  129.     register __d5 long ySize,register __d6 unsigned long minterm,register __d7 unsigned long mask,
  130.     register __a2 PLANEPTR tempA );
  131. LONG (__asm *OldBltBitMap)(register __a0 struct BitMap *srcBitMap,
  132.     register __d0 long xSrc,register __d1 long ySrc,
  133.     register __a1 struct BitMap *destBitMap,
  134.     register __d2 long xDest,register __d3 long yDest,register __d4 long xSize,
  135.     register __d5 long ySize,register __d6 unsigned long minterm,register __d7 unsigned long mask,
  136.     register __a2 PLANEPTR tempA );
  137.  
  138. void __asm NewBltBitMapRastPort(register __a0 struct BitMap *srcBitMap,
  139.         register __d0 long xSrc,register __d1 long ySrc,
  140.         register __a1 struct RastPort *destRP,
  141.         register __d2 long xDest,register __d3 long yDest,
  142.         register __d4 long xSize,register __d5 long ySize,
  143.         register __d6 unsigned long minterm );
  144. void (__asm *OldBltBitMapRastPort)(register __a0 struct BitMap *srcBitMap,
  145.         register __d0 long xSrc,register __d1 long ySrc,
  146.         register __a1 struct RastPort *destRP,
  147.         register __d2 long xDest,register __d3 long yDest,
  148.         register __d4 long xSize,register __d5 long ySize,
  149.         register __d6 unsigned long minterm );
  150.  
  151. void __asm NewBltTemplate(register __a0 PLANEPTR source,register __d0 long xSrc,register __d1 long srcMod,
  152.     register __a1 struct RastPort *destRP,register __d2 long xDest,register __d3 long yDest,
  153.     register __d4 long xSize,register __d5 long ySize );
  154. void (__asm *OldBltTemplate)(register __a0 PLANEPTR source,register __d0 long xSrc,register __d1 long srcMod,
  155.     register __a1 struct RastPort *destRP,register __d2 long xDest,register __d3 long yDest,
  156.     register __d4 long xSize,register __d5 long ySize );
  157.  
  158. void __asm NewBltClear(register __a1 PLANEPTR memBlock,register __d0 unsigned long byteCount,
  159.     register __d1 unsigned long flags );
  160. void (__asm *OldBltClear)(register __a1 PLANEPTR memBlock,register __d0 unsigned long byteCount,
  161.     register __d1 unsigned long flags );
  162.  
  163. void __asm NewBltPattern(register __a1 struct RastPort *rp,register __a0 PLANEPTR mask,
  164.     register __d0 long xMin,register __d1 long yMin,
  165.     register __d2 long xMax,register __d3 long yMax,register __d4 unsigned long maskBPR );
  166. void (__asm *OldBltPattern)(register __a1 struct RastPort *rp,register __a0 PLANEPTR mask,
  167.     register __d0 long xMin,register __d1 long yMin,
  168.     register __d2 long xMax,register __d3 long yMax,register __d4 unsigned long maskBPR );
  169.  
  170. // Intuifunktionen :
  171.  
  172. struct Screen *(__asm NewOpenScreenTagList)(register __a0 struct NewScreen *newScreen,register __a1 struct TagItem *tagList );
  173. LONG (__asm *OldOpenScreenTagList)(register __a0 struct NewScreen *newScreen,register __a1 struct TagItem *tagList );
  174. /*
  175. struct Screen *OpenScreenTags( struct NewScreen *newScreen,
  176.     unsigned long tag1Type, ... );
  177. */
  178. BOOL __asm NewCloseScreen(register __a0 struct Screen *screen);
  179. BOOL (__asm *OldCloseScreen)(register __a0 struct Screen *screen);
  180.  
  181. void main(int argc, char *argv[])
  182. {
  183. /*    800x600 : MODE_800x600_NI 
  184.      1024x768 : MODE_1024x768_NI ,  BOARD0_OSC2=67.667MHZ 
  185.     1024x1024 : MODE_1024x1024_NI , 80.00MHZ
  186. */
  187.     UBYTE *Command0 = "c:loadtiga "\
  188.                        "BOARD0_MODE=MODE_800x600_NI "\
  189.                        "BOARD0_OSC1=36.000MHZ "\
  190.                        "BOARD0_OSC2=67.667MHZ "\
  191.                        "SETUP=FFB62460 "\
  192.                        " >NIL:";
  193.  
  194. //    SystemTags("avail flush >nil:",TAG_DONE);
  195. //    if (SystemTags(Command0,TAG_DONE)) CloseTiga(20);  // couldn't load the tiga !
  196.  
  197.     if (!(GfxBase=(struct Library *)OpenLibrary("graphics.library",36L)))              CloseTiga(10);
  198.      if (!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",36L))) CloseTiga(10);
  199.     if (!(GraphicsBase=(struct Library *)OpenLibrary("gfx.library",0l)))               CloseTiga(10);
  200.     
  201.     if ((argc==2)&&(!strncmp(argv[1],"n",1))) NoExit  = TRUE;
  202.     if (argc==0) NoExit = FALSE;
  203.  
  204.     Delay(30);
  205.     GfxClearScreen(NULL);
  206.  
  207.     GfxSetUpScreen(IntuitionBase->ActiveScreen);
  208.     Forbid();
  209.     InstallPatch();   
  210.     Permit();
  211.  
  212.     INSTALLED = TRUE;
  213.  
  214.     puts("A2410 TIGA driver");
  215.     puts("(c)1994 jürgen schober");
  216.     puts("functions patched ...");
  217.  
  218.     printf("press <Enter> to remove patches ");
  219.     getchar();
  220.  
  221.     CloseTiga(0);
  222. }/*main*/
  223.  
  224. void CloseTiga(int code)
  225. {
  226.     if (INSTALLED)
  227.     {
  228.         Forbid();
  229.         RemovePatch();
  230.         Permit();
  231.         puts("\npatches removed ...");
  232.     }
  233.  
  234.     if (IntuitionBase)  CloseLibrary((struct Library*)IntuitionBase);
  235.     if (GfxBase)        CloseLibrary(GfxBase);
  236.     if (GraphicsBase)   CloseLibrary(GraphicsBase);
  237.     exit(code); 
  238. }
  239.  
  240. void RemovePatch(void)
  241. {
  242. /* Graphics primitives : */
  243.  
  244. //    SetFunction(GfxBase,-0x00ea,(APTR)OldSetRast);       //  gfx SetRast() function
  245.     SetFunction(GfxBase,-0x0144,(APTR)OldWritePixel);    //  gfx WritePixel() function
  246.     SetFunction(GfxBase,-0x00F6,(APTR)OldDraw);          //  gfx Move() function
  247.     SetFunction(GfxBase,-0x0132,(APTR)OldRectFill);      //  gfx RectFill() function
  248.  
  249.     SetFunction(GfxBase,-0x00B4,(APTR)OldDrawEllipse);   //  gfx DrawEllipse() function
  250.     SetFunction(GfxBase,-0x00BA,(APTR)OldAreaEllipse);   //  gfx AreaEllipse() function
  251.  
  252.     SetFunction(GfxBase,-0x0120,(APTR)OldSetRGB4);       //  gfx SetRGB4() function
  253.     SetFunction(GfxBase,-0x0354,(APTR)OldSetRGB32);      //  gfx SetRGB32() function
  254.  
  255. /* Text Functions : */
  256.  
  257.     SetFunction(GfxBase,-0x003C,(APTR)OldText);          //  gfx Text() function
  258.     SetFunction(GfxBase,-0x0042,(APTR)OldSetFont);       //  gfx SetFont()
  259.  
  260. /* BitMap Functions : */
  261.  
  262.     SetFunction(GfxBase,-0x001E,(APTR)OldBltBitMap);     //  gfx BltBitMap() function
  263. /*
  264.     SetFunction(GfxBase,-0x0024,(APTR)OldBltTemplate); 
  265.     SetFunction(GfxBase,-0x012c,(APTR)OldBltClear);
  266.     SetFunction(GfxBase,-0x0138,(APTR)OldBltPattern);
  267. */
  268.     SetFunction(GfxBase,-0x0108,(APTR)OldAreaEnd);       //  gfx AreaEnd() function
  269.  
  270. //    SetFunction(GfxBase,-0x01aa,(APTR)OldMoveSprite);    //  
  271. /*  ----------------------------------------------------------------------
  272.     Disabled Functions :
  273.  
  274.     SetFunction(GfxBase,-0x002a,(APTR)OldClearEOL);
  275.     SetFunction(GfxBase,-0x0030,(APTR)OldClearScreen);
  276.  
  277.     SetFunction(GfxBase,-0x020a,(APTR)OldClearRectRegion);
  278.     SetFunction(GfxBase,-0x0210,(APTR)OldClearRegion);
  279.  
  280. *** Never Patched Functions : ***
  281.  
  282. **  GfxMove 100% kompatibel zu Move() -> patch disabled **
  283.  
  284.     SetFunction(GfxBase, -0xF0,(APTR)OldMove);  
  285.  
  286. ** BlitBitmapRastPort() ruft BltBitMap() auf **
  287.  
  288.     SetFunction(GfxBase,-0x025e,(APTR)OldBltBitMapRastPort);
  289.  
  290.     SetFunction(GfxBase,-0x0150,(APTR)OldPolyDraw);      //  gfx PolyDraw() function
  291.     SetFunction(GfxBase,-0x00FC,(APTR)OldAreaMove);      //  gfx AreaMove() function
  292.     SetFunction(GfxBase,-0x0102,(APTR)OldAreaDraw);      //  gfx AreaDraw() function
  293. */
  294.  
  295. /* Some Intuition functions : */
  296.  
  297.     SetFunction((struct Library *)IntuitionBase,-0x0264,(APTR)OldOpenScreenTagList);
  298. //    SetFunction((struct Library *)IntuitionBase,-0x0042,(APTR)OldCloseScreen);
  299. }
  300.  
  301. void InstallPatch(void)
  302. {
  303. /* Graphics primitives : */
  304.  
  305. //    OldSetRast    = (APTR)SetFunction(GfxBase,-0x00ea,(APTR)NewSetRast);
  306.     OldWritePixel = (APTR)SetFunction(GfxBase,-0x0144,(APTR)NewWritePixel);  //  gfx WritePixel() function
  307.     OldDraw       = (APTR)SetFunction(GfxBase,-0x00F6,(APTR)NewDraw);        //  gfx Move() function
  308.     OldRectFill   = (APTR)SetFunction(GfxBase,-0x0132,(APTR)NewRectFill);    //  gfx RectFilll() function
  309.  
  310.     OldDrawEllipse= (APTR)SetFunction(GfxBase,-0x00B4,(APTR)NewDrawEllipse); //  gfx DrawEllipse() function
  311.     OldAreaEllipse= (APTR)SetFunction(GfxBase,-0x00BA,(APTR)NewAreaEllipse); //  gfx AreaEllipse() function
  312.  
  313.     OldSetRGB4    = (APTR)SetFunction(GfxBase,-0x0120,(APTR)NewSetRGB4);     //  gfx SetRGB4() function
  314.     OldSetRGB32   = (APTR)SetFunction(GfxBase,-0x0354,(APTR)NewSetRGB32);    //  gfx SetRGB32() function
  315.  
  316. /* Text Functions : */
  317.  
  318.     OldText       = (APTR)SetFunction(GfxBase,-0x003C,(APTR)NewText);        //  gfx Text() function
  319.     OldSetFont    = (APTR)SetFunction(GfxBase,-0x0042,(APTR)NewSetFont);     //  gfx SetFont()
  320.  
  321. /* BitMap Functions : */
  322.  
  323.     OldBltBitMap  = (APTR)SetFunction(GfxBase,-0x001E,(APTR)NewBltBitMap);   //  gfx BltBitMap() function
  324. /*
  325.     OldBltTemplate= (APTR)SetFunction(GfxBase,-0x0024,(APTR)NewBltTemplate); 
  326.     OldBltClear   = (APTR)SetFunction(GfxBase,-0x012c,(APTR)NewBltClear);
  327.     OldBltPattern = (APTR)SetFunction(GfxBase,-0x0138,(APTR)NewBltPattern);
  328. */
  329.     OldAreaEnd    = (APTR)SetFunction(GfxBase,-0x0108,(APTR)NewAreaEnd);     //  gfx AreaEnd() function
  330.  
  331. //    OldMoveSprite = (APTR)SetFunction(GfxBase,-0x01aa,(APTR)NewMoveSprite); 
  332. /*  ----------------------------------------------------------------------
  333.     Disabled Functions :
  334.  
  335.     OldClearEOL   = (APTR)SetFunction(GfxBase,-0x002a,(APTR)NewClearEOL);
  336.     OldClearScreen= (APTR)SetFunction(GfxBase,-0x0030,(APTR)NewClearScreen);
  337.  
  338.     OldClearRectRegion = (APTR)SetFunction(GfxBase,-0x020a,(APTR)NewClearRectRegion);
  339.     OldClearRegion = (APTR)SetFunction(GfxBase,-0x0210,(APTR)NewClearRegion);
  340.  
  341. *** Never Patched Functions : ***
  342.  
  343. **  GfxMove() 100% kompatibel zu Move() -> patch disabled ! **
  344.  
  345.     OldMove       = (APTR)SetFunction(GfxBase,-0x00F0,(APTR)NewMove);        
  346.  
  347. ** BlitBitmapRastPort() ruft BltBitMap() auf **
  348.  
  349.     OldBltBitMapRastPort  = (APTR)SetFunction(GfxBase,-0x025e,(APTR)NewBltBitMapRastPort);
  350.  
  351.     OldPolyDraw   = (APTR)SetFunction(GfxBase,-0x0150,(APTR)NewPolyDraw);    //  gfx PolyDraw() function
  352.     OldAreaMove   = (APTR)SetFunction(GfxBase,-0x00FC,(APTR)NewAreaMove);    //  gfx AreaMove() function
  353.     OldAreaDraw   = (APTR)SetFunction(GfxBase,-0x0102,(APTR)NewAreaDraw);    //  gfx AreaDraw() function
  354.  
  355. */
  356.  
  357. /* Some Intiuion functions : */
  358.  
  359.     OldOpenScreenTagList = (APTR)SetFunction((struct Library *)IntuitionBase,-0x0264,(APTR)NewOpenScreenTagList);
  360. //    OldCloseScreen       = (APTR)SetFunction((struct Library *)IntuitionBase,-0x0042,(APTR)NewCloseScreen);
  361. }
  362.  
  363.  
  364. /*  ---------------------------------------------------------*/
  365.  
  366. /*                   NEUE FUNKTIONEN                         */
  367.  
  368. /*  ---------------------------------------------------------*/
  369.  
  370. BOOL __asm NewClearRectRegion(register __a0 struct Region *region,register __a1 struct Rectangle *rectangle )
  371. {
  372.     return(TRUE);
  373. }
  374.  
  375. void __asm NewClearRegion(register __a0 struct Region *region )
  376. {
  377. }
  378.  
  379. void __asm NewClearEOL(register __a1 struct RastPort *rp )  // -0x002a
  380. {
  381.     putreg(REG_A6,(LONG)GfxBase);
  382.     OldClearEOL(rp);
  383. }
  384.  
  385. void __asm NewClearScreen(register __a1 struct RastPort *rp )  // -0x0030
  386. {
  387.     putreg(REG_A6,(LONG)GfxBase);
  388.     OldClearScreen(rp);
  389. }
  390.  
  391. void __asm NewSetRast(register __a1 struct RastPort *rp,register __d0 unsigned long pen )
  392. {
  393.     if (GfxCheckBitMap(rp->BitMap))
  394.         GfxSetRast(rp,pen);
  395.     else
  396.     {
  397.         putreg(REG_A6,(LONG)GfxBase);
  398.          OldSetRast(rp,pen); // original function
  399.     }
  400. }
  401.  
  402. /* graphics Move() */
  403. void __asm NewMove(register __a1 struct RastPort * rp,register __d0 SHORT x,register __d1 SHORT y)
  404. {
  405.     OldMove(rp,x,y);
  406.     //GfxMove(rp,x,y); // New own function - 100% ident mit Move !
  407. }
  408.  
  409. /* graphics Draw() */
  410. void __asm NewDraw(register __a1 struct RastPort * rp,register __d0 SHORT x,register __d1 SHORT y)
  411. {
  412.     if (GfxCheckBitMap(rp->BitMap))
  413.         GfxDraw(rp,x,y); // New own function
  414.     else
  415.     {
  416.         putreg(REG_A6,(LONG)GfxBase);
  417.         OldDraw(rp,x,y); // original function
  418.     }
  419. }
  420.  
  421. void __asm NewRectFill(register __a1 struct RastPort *rp,register __d0 long xMin,register __d1 long yMin,
  422.                       register __d2 long xMax,register __d3 long yMax )
  423. {
  424.     if (GfxCheckBitMap(rp->BitMap))
  425.         GfxRectFill(rp,xMin,yMin,xMax,yMax); // New own function
  426.     else
  427.     {
  428.         putreg(REG_A6,(LONG)GfxBase);
  429.         OldRectFill(rp,xMin,yMin,xMax,yMax); // original function
  430.     }
  431. }
  432.  
  433. LONG __asm NewWritePixel(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y )
  434. {
  435.     if (GfxCheckBitMap(rp->BitMap))
  436.         GfxWritePixel(rp,x,y); // New own function
  437.     else
  438.     {
  439.         putreg(REG_A6,(LONG)GfxBase);
  440.         return(OldWritePixel(rp,x,y)); // original function
  441.     }
  442. }
  443.  
  444. void __asm NewDrawEllipse(register __a1 struct RastPort *rp,register __d0 long xCenter,
  445.                          register __d1 long yCenter,register __d2 long a,register __d3 long b)
  446. {
  447.         GfxDrawEllipse(rp,xCenter,yCenter,a,b); // New own function
  448.         putreg(REG_A6,(LONG)GfxBase);
  449.         OldDrawEllipse(rp,xCenter,yCenter,a,b); // original function
  450. /*
  451.     if (GfxCheckBitMap(rp->BitMap))
  452.         GfxDrawEllipse(rp,xCenter,yCenter,a,b); // New own function
  453.     else
  454.     {
  455.         putreg(REG_A6,(LONG)GfxBase);
  456.         OldDrawEllipse(rp,xCenter,yCenter,a,b); // original function
  457.     }
  458. */
  459. }
  460.  
  461. void __asm NewAreaEllipse(register __a1 struct RastPort *rp,register __d0 long xCenter,
  462.                          register __d1 long yCenter,register __d2 long a,register __d3 long b)
  463. {
  464.         GfxAreaEllipse(rp,xCenter,yCenter,a,b); // New own function
  465.         putreg(REG_A6,(LONG)GfxBase);
  466.         OldAreaEllipse(rp,xCenter,yCenter,a,b); // original function
  467. /*
  468.     if (GfxCheckBitMap(rp->BitMap))
  469.         GfxAreaEllipse(rp,xCenter,yCenter,a,b); // New own function
  470.     else
  471.     {
  472.         putreg(REG_A6,(LONG)GfxBase);
  473.         OldAreaEllipse(rp,xCenter,yCenter,a,b); // original function
  474.     }
  475. */
  476. }
  477.  
  478. LONG __asm NewText(register __a1 struct RastPort *rp,register __a0 STRPTR string,register __d0 unsigned long count )
  479. {
  480.     if (GfxCheckBitMap(rp->BitMap))
  481.         return(GfxText(rp,string,count));
  482.     else
  483.     {
  484.         putreg(REG_A6,(LONG)GfxBase);
  485.         return(OldText(rp,string,count)); // original function
  486.     }
  487. }
  488.  
  489. LONG __asm NewSetFont(register __a1 struct RastPort *rp,register __a0 struct TextFont *textFont )
  490. {
  491.     return(GfxSetFont(rp,textFont));
  492.  
  493. /*
  494.     if (GfxCheckRP(rp))
  495.     {
  496.         GfxSetFont(rp,textFont);
  497.     }
  498.     else
  499.     {
  500.         putreg(REG_A6,(LONG)GfxBase);
  501.         return((LONG)OldSetFont(rp,textFont));
  502.     }
  503. */
  504. }
  505.  
  506. void __asm NewSetRGB4(register __a0 struct ViewPort *vp,register __d0 long index,register __d1 unsigned long red,
  507.                      register __d2 unsigned long green,register __d3 unsigned long blue )
  508. {
  509.     if (GfxCheckVP(vp))
  510.         GfxSetRGB4(vp,index,red,green,blue);
  511.     else
  512.     {
  513.         putreg(REG_A6,(LONG)GfxBase);
  514.         OldSetRGB4(vp,index,red,green,blue);
  515.     }
  516. }
  517.  
  518. void __asm NewSetRGB32(register __a0 struct ViewPort *vp,register __d0 long n,register __d1 unsigned long r,
  519.                      register __d2 unsigned long g,register __d3 unsigned long b)
  520. {
  521.     if (GfxCheckVP(vp))
  522.         GfxSetRGB32(vp,n,r,g,b);
  523.     else
  524.     {
  525.         putreg(REG_A6,(LONG)GfxBase);
  526.         OldSetRGB32(vp,n,r,g,b);
  527.     }
  528. }
  529.  
  530. void __asm NewPolyDraw(register __a1 struct RastPort *rp,register __d0 long count,register __a0 WORD *polyTable )
  531. {
  532.     if (GfxCheckBitMap(rp->BitMap))
  533.         GfxPolyDraw(rp,count,polyTable);
  534.     else
  535.     {
  536.         putreg(REG_A6,(LONG)GfxBase);
  537.         PolyDraw(rp,count,polyTable);
  538.     }
  539. }
  540.  
  541. LONG __asm NewAreaMove(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y)
  542. {
  543. /*
  544.     if (GfxCheckBitMap(rp->BitMap))
  545.         return(GfxAreaMove(rp,x,y));
  546.     else
  547.  
  548.     {
  549.         putreg(REG_A6,(LONG)GfxBase);
  550.         return((LONG)OldAreaMove(rp,x,y));
  551.     }
  552. */
  553.     return(0);
  554. }
  555.  
  556. LONG __asm NewAreaDraw(register __a1 struct RastPort *rp,register __d0 long x,register __d1 long y)
  557. {
  558. /*
  559.     if (GfxCheckBitMap(rp->BitMap))
  560.         return(GfxAreaDraw(rp,x,y));
  561.     else
  562.     {
  563.         putreg(REG_A6,(LONG)GfxBase);
  564.         return((LONG)OldAreaDraw(rp,x,y));
  565.     }
  566. */
  567.     return(0);
  568. }
  569.  
  570. LONG __asm NewAreaEnd(register __a1 struct RastPort *rp)
  571. {
  572.     if (GfxCheckBitMap(rp->BitMap))
  573.         return(GfxAreaEnd(rp));
  574.     else
  575.     {
  576.         putreg(REG_A6,(LONG)GfxBase);
  577.         return((LONG)OldAreaEnd(rp));
  578.     }
  579. }
  580.  
  581. LONG __asm NewBltBitMap(register __a0 struct BitMap *srcBitMap,
  582.     register __d0 long xSrc,register __d1 long ySrc,
  583.     register __a1 struct BitMap *destBitMap,
  584.     register __d2 long xDest,register __d3 long yDest,register __d4 long xSize,
  585.     register __d5 long ySize,register __d6 unsigned long minterm,register __d7 unsigned long mask,
  586.     register __a2 PLANEPTR tempA )
  587. {
  588.  
  589.     if (GfxCheckBitMap(destBitMap)||GfxCheckBitMap(destBitMap))
  590.         return(GfxBltBitMap(srcBitMap,xSrc,ySrc,destBitMap,xDest,yDest,xSize,ySize,minterm,mask,tempA));
  591.     else
  592.     {
  593.         // Flush Bitmap :
  594.         GfxBltBitMap(srcBitMap,xSrc,ySrc,destBitMap,xDest,yDest,xSize,ySize,minterm,mask,tempA);
  595.  
  596.         putreg(REG_A6,(LONG)GfxBase);
  597.         return((OldBltBitMap(srcBitMap,xSrc,ySrc,destBitMap,xDest,yDest,xSize,ySize,minterm,mask,tempA)));
  598.     }
  599. }
  600.  
  601. void __asm NewBltBitMapRastPort(register __a0 struct BitMap *srcBitMap,
  602.         register __d0 long xSrc,register __d1 long ySrc,
  603.         register __a1 struct RastPort *destRP,
  604.         register __d2 long xDest,register __d3 long yDest,
  605.         register __d4 long xSize,register __d5 long ySize,
  606.         register __d6 unsigned long minterm )
  607. {
  608. //        GfxBltBitMap(srcBitMap,xSrc,ySrc,destRP->BitMap,xDest,yDest,xSize,ySize,minterm,0xff,NULL);
  609. }
  610.  
  611. void __asm NewBltTemplate(register __a0 PLANEPTR source,register __d0 long xSrc,register __d1 long srcMod,
  612.     register __a1 struct RastPort *destRP,register __d2 long xDest,register __d3 long yDest,
  613.     register __d4 long xSize,register __d5 long ySize )
  614. {
  615. /*
  616.     putreg(REG_A6,(LONG)GfxBase);
  617.     OldBltTemplate(source,xSrc,srcMod,destRP,xDest,yDest,xSize,ySize);
  618. */
  619. }
  620.  
  621. void __asm NewBltClear(register __a1 PLANEPTR memBlock,register __d0 unsigned long byteCount,
  622.     register __d1 unsigned long flags )
  623. {
  624.     register i;
  625.     UBYTE *mem;
  626. /*
  627.     mem = (UBYTE*)memBlock; 
  628.     for (i =  0; i< byteCount; i++) 
  629.         mem[i] = 0;
  630.  
  631.     putreg(REG_A6,(LONG)GfxBase);
  632.     OldBltClear(memBlock,byteCount,flags);
  633. */
  634. }
  635.  
  636. void __asm NewBltPattern(register __a1 struct RastPort *rp,register __a0 PLANEPTR mask,
  637.     register __d0 long xMin,register __d1 long yMin,
  638.     register __d2 long xMax,register __d3 long yMax,register __d4 unsigned long maskBPR )
  639. {
  640.       putreg(REG_A6,(LONG)GfxBase);
  641. //    OldBltPattern(rp,mask,xMin,yMin,xMax,yMax,maskBPR);
  642. }
  643.  
  644. void __asm NewMoveSprite(register __a0 struct ViewPort vp,register __a1 struct SimpleSprite *sprite,register __d0 long x,register __d1 long y)
  645. {
  646.     if (GfxCheckVP(vp))
  647.         GfxPointerXY(NULL,x,y);
  648.     else
  649.     {
  650.         putreg(REG_A6,(LONG)GfxBase);
  651.         OldMoveSprite(vp,sprite,x,y);
  652.     }
  653. }
  654.  
  655. /* ------------------------------*
  656.  *        Intui functions :      *
  657.  * ------------------------------*/
  658.  
  659.  
  660. struct Screen *(__asm NewOpenScreenTagList)(register __a0 struct NewScreen *newScreen,
  661.     register __a1 struct TagItem *tagList )
  662. {
  663. /*
  664.     this patch does not work ! I do not know why. But it should work this way.
  665.     Although if I only call OldOpenScreenTagList(newScreen,tagList) - the machine crashes (?)
  666.  
  667.     Well, look in the while loop. It shows how the display_ID is parsed and what is done if
  668.     the TIGA_ID is found ! I open a standard Amiga Screen now. Well I can use a 4 BitPlane
  669.     and correct it up to 8 Planes after opening the screen - I just use it for the functions
  670.     OpenScreen() uses. The RastPort does always use 8 Bit depth (eg. RP->FgPen = 8 Bit !)
  671.     What is not done now is copying the tags from the calling programm to the OpenScreen() -
  672.     it will be done in the next version. I used "patch_tags" (see below) for testing.
  673.     I used also a LowRes - Screen to get more then 16 Colors. But then I have strange looking
  674.     Systemgadgets ! I would be happy, if you would find out, why the patch does not work. :-(
  675.  
  676.     Allright. That's where you can hook into. Hope it works !
  677. */
  678. /*
  679.  
  680.     struct TagItem *tags;
  681.     ULONG TIGA_ID = 0L;
  682.     struct Screen *sc;
  683.     struct TagItem patch_tags[] =  {
  684.                                         SA_Width,800,   
  685.                                         SA_Height,600,
  686.                                         SA_Depth,4,
  687.                                         TAG_DONE,TAG_DONE
  688.                                    };
  689.  
  690.     tags = tagList;
  691.     while ((tags->ti_Tag!=TAG_DONE)&&(tags->ti_Data!=TAG_DONE))
  692.     {
  693.         switch (tags->ti_Tag)
  694.         {
  695.             case SA_DisplayID :
  696.                                 {
  697. // That's what should be parsed, when a TIGA_ID is working !
  698. //                                    if ((tags->ti_Data & A2410_MONITOR_ID) == A2410_MONITOR_ID)
  699.                                     if ((tags->ti_Data & (NTSC_MONITOR_ID|PAL_MONITOR_ID|LORES_KEY)))
  700.                                     {
  701. //                                        TIGA_ID = tags->ti_Data;
  702. // Here, the Mode should be parsed ...
  703.  
  704.                                         putreg(REG_A6,(LONG)IntuitionBase);
  705.                                         if (sc = (struct Screen *)(OldOpenScreenTagList(newScreen,(struct TagItem *)patch_tags)))
  706.                                         {
  707.                                             GfxSetUpScreen(sc);
  708.                                             return((long)sc);
  709.                                         }
  710.                                     }
  711.                                     return(0);
  712.                                     break;
  713.                                 }
  714.             default : break;
  715.         }
  716.         tags++;
  717.     }
  718. */
  719.     putreg(REG_A6,(LONG)IntuitionBase);
  720.     return((struct Screen *)OldOpenScreenTagList(newScreen,tagList));
  721. }
  722.  
  723. BOOL __asm NewCloseScreen(register __a0 struct Screen *screen )
  724. {
  725. /*
  726.     GfxRemoveScreen(screen);
  727.     return(//GfxCloseScreen(screen));
  728. */
  729.     putreg(REG_A6,(LONG)IntuitionBase);
  730.     return(NewCloseScreen(screen));
  731.  
  732. }
  733.  
  734. /*
  735. MouseImage()
  736. */